package com.perfma.xtest.tool;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.data.ChartMultiSeriesRenderData;
import com.deepoove.poi.data.SeriesRenderData;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;

import java.io.FileOutputStream;
import java.util.List;
import java.util.Map;

/**
 * @author: junhui.si
 * @date: 2020-10-23 14:52
 **/
@Slf4j
public class WordDemo4 {

//    public static void main(String[] args) {
//        try {
//            String inputFileName = TestFileUtil.getPath() + "report-t2.docx";
//
//            // 配置，使用spring EL表达式
//            Configure configure = Configure.builder().useSpringEL().build();
//            XWPFTemplate template = XWPFTemplate.compile(inputFileName, configure);
//
//            Map<String, Object> result = Maps.newHashMap();
//            result.put("reportResult", "jhhhh");
//
//            // 报告结论-测试
//            List<Map<String, Object>> xxList = Lists.newArrayList();
//            xxList.add(getTestDateImg2());
//            xxList.add(getTestDateImg2());
//            xxList.add(getTestDateImg2());
//            List<Map<String, Object>> xList = Lists.newArrayList();
//            Map<String, Object> map1 = Maps.newHashMap();
//            map1.put("xxList",xxList);
//            xList.add(map1);
//            xList.add(map1);
//            result.put("xList", xList);
//            result.put("sList", xxList);
//
//
//            template.render(result);
//
//            String outputFileName = TestFileUtil.getPath() + "report2.docx";
//            FileOutputStream out = new FileOutputStream(outputFileName);
//            template.write(out);
//            out.flush();
//            out.close();
//            template.close();
//        } catch (Exception e) {
//            log.error("error.", e);
//        }
//    }
//
//    public static Map<String, Object> getTestDateImg2() {
//        ChartMultiSeriesRenderData chart = new ChartMultiSeriesRenderData();
//        chart.setChartTitle("MyChart" + System.currentTimeMillis());
//        chart.setCategories(new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9"});
//        List<SeriesRenderData> seriesRenderData = Lists.newArrayList();
//        seriesRenderData.add(new SeriesRenderData("事务1", new Double[]{15.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0}));
//        seriesRenderData.add(new SeriesRenderData("事务2", new Double[]{23.0, 19.0, 19.0, 19.0, 6.0, 36.0, 6.0, 6.0, 6.0}));
//        chart.setSeriesDatas(seriesRenderData);
//
//        Map<String, Object> result = Maps.newHashMap();
//        result.put("chart", chart);
//        return result;
//    }
}
